package zuk.clipvietfun;


import zuk.clipvietfun.clip.FragmentClip;
import zuk.clipvietfun.clip.FragmentClipAllList;
import zuk.clipvietfun.home.FragmentHome;
import zuk.clipvietfun.likeandhistory.FragmentLike;
import zuk.clipvietfun.plus.Const;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
public class MPagerAdapter extends  FragmentPagerAdapter {
	public static final String[] MENU = {
		"HOME",
		"HOT",
		"VUI",
		"SHOCK",
		"HÀI",
		"NHẠC",
		"TV SHOW",
	"LIKE"};
	Handler settab;
	public MPagerAdapter(FragmentManager fm, Handler settab) {
		super(fm);
		this.settab = settab;
	}

	@Override
	public Fragment getItem(int position) {
		Fragment fragment = null;
		boolean isAllList=true;
		switch (position) {
		case 0:
			fragment = new FragmentHome(settab);
			break;
		case 7:
			fragment = new FragmentLike();
			break;
		default:
			String i = Const.swTab(position);
			if(isAllList)
				fragment = new FragmentClipAllList(i);
			else
				fragment = new FragmentClip(i);
			break;
		}

		return fragment;
	}

	@Override
	public int getCount() {
		return MENU.length;
		//		return 2;
	}

	@Override
	public CharSequence getPageTitle(int position) {
		String title = MENU[position];
		return title;
	}


}
